package common.com.androidbase.datarequest;

import android.os.Parcel;
import android.os.Parcelable;

import com.android.sohu.sdk.common.toolbox.LogUtils;
import com.android.sohu.sdk.common.toolbox.StringUtils;
import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

/**
 * 专辑详情
 *
 * @author kimwang
 */
public class AlbumInfoModel implements Cloneable, Parcelable {
    private static final String TAG = "AlbumInfoModel";
    /**
     * 此为服务器返回的data_type，为了兼容升级。表示返回结果类型，具体含义参考http://mwiki.sohuno.com/pages/
     * viewpage.action?pageId=12456047
     */
    private int data_type;
    private long aid; // 专辑id
    private long program_id; // 节目id
    private int is_download; // 是否可下载
    private int ip_limit; // 是否ip限制
    private int mobile_limit; // 播放限制, 0:不限制，1:跳h5播，2:禁止播放
    private String album_name; // 专辑名
    private String album_sub_name; // 专辑子标题
    private String album_desc; // 专辑描述
    private int is_original_code; // 是否原画
    private String ver_big_pic; // 横向大图
    private String hor_big_pic; // 纵向大图
    private String ver_high_pic; // 横向高清图
    private String hor_high_pic; // 纵向高清图
    private long cid; // 分类id
    private String cate_code; // 分类ids，如："115;115101;115103"
    private String second_cate_name; // 二级分类名称，如："搞笑;冒险"
    @SerializedName("album_publish_time")
    private String publish_time; // 专辑发布时间
    private int is_trailer; // 是否片花
    private int is_titbits; // 是否花絮
    private int titbits_aid; // 花絮id
    private String director; // 导演
    private String main_actor; // 主演
    private String actor; // 演员
    private String moderator; // 主持人
    private long area_id; // 地域id
    private String area; // 地域
    private String tv_station; // 电视台
    private String tv_source; // 电视频道
    private String year; // 出品年份
    private long total_video_count; // 视频总数
    private long latest_video_count; // 最新的视频集数
    private float score; // 专辑评分
    private long play_count; // 专辑播放数
    private String updateNotification; // 更新提示
    private String dubbing; // 配音
    private String show_date; // (电影)上映日期
    private String original_album_url; // 主站专辑地址
    /**
     * 广告版权
     */
    private long crid;
    /**
     * 电视类型
     */
    // private long tv_type;
    private String award; // 获奖情况
    private List<AlbumInfoCompany> company;
    /**
     * 工作室 或者用户信息
     */
    private PgcAccountInfoModel user;

    /**
     * 小背景图
     */
    private String bg_small_pic;
    /**
     * 高清背景图
     */
    private String bg_high_pic;
    /**
     * 原背景图
     */
    private String bg_pic;
    /**
     * 背景大图，不一定有，另外链接的图片可能不存在，使用方注意判断
     */
    private String bg_big_pic;
    /**
     * 横图,16:9,尺寸640 * 360
     */
    private String hor_w16_pic;
    /**
     * 竖图，尺寸480 * 660
     */
    private String ver_w12_pic;

    private String distribution_firm_pic; // 发行公司图片
    private String background_image_pic; // 背景大图
    private ArrayList<YMS> yms; // json数组

    private ArrayList<AppPlatformModel> video_list;// 剧集列表
    private int site;
    private int is_album;// 是否专辑. 1:专辑， 0:非专辑
    private String tip;// 图片介绍
    private String tips; // pgc更新提醒
    private String tv_desc;// 简介
    private String tv_name;// 视频名称
    private long vid;// 视频id
    private float douban_score; // 豆瓣评分
    private int season;

    private float imdb_score;

    private String alias_name;
    private String original_work;
    private String language;
    private int tv_is_danmu;// 0 关闭 1，弹幕开默认不显示 2，弹幕开默认显示

    // 新搜索接口增加字段
    private ArrayList<String> high_light; // hight light
    private ArrayList<AppPlatformVideoModel> videos; // 搜索接口中的剧集列表
    private long total_duration;

    private int download_type; // 0:不能下载、1:可以下载、20:会员下载 ：
                               // 5.0.1开始加上的，不再使用原来的isDownload

    private int effective; // 是否有效，0无效

    private String whole_source; // 搜索外网源标识

    public AlbumInfoModel() {
    }

    /**
     * 使用ListResourcesDataType类 获取分类类型
     *
     * @return
     */
    public int getDataType() {
        return data_type;
    }

    public void setDataType(int data_type) {
        this.data_type = data_type;
    }

    public long getAid() {
        return aid;
    }

    public void setAid(long aid) {
        this.aid = aid;
    }

    public float getImdbScore() {
        return imdb_score;
    }

    public void setImdbScore(float imdb_score) {
        this.imdb_score = imdb_score;
    }

    public long getProgram_id() {
        return program_id;
    }

    public void setProgram_id(long program_id) {
        this.program_id = program_id;
    }

    public int getIs_download() {
        return is_download;
    }

    /**
     * 是否下载
     *
     * @return
     */
    public boolean isDownload() {

        if (is_download == 1) {
            return true;
        }

        return false;
    }

    public void setIs_download(int is_download) {
        this.is_download = is_download;
    }

    public int getIp_limit() {
        return ip_limit;
    }

    public void setIp_limit(int ip_limit) {
        this.ip_limit = ip_limit;
    }

    public int getMobile_limit() {
        return mobile_limit;
    }

    public void setMobile_limit(int mobile_limit) {
        this.mobile_limit = mobile_limit;
    }

    public String getAlbum_name() {
        return album_name;
    }

    public void setAlbum_name(String album_name) {
        this.album_name = album_name;
    }

    public String getAlbum_sub_name() {
        return album_sub_name;
    }

    public void setAlbum_sub_name(String album_sub_name) {
        this.album_sub_name = album_sub_name;
    }

    public String getAlbum_desc() {
        return album_desc;
    }

    public void setAlbum_desc(String album_desc) {
        this.album_desc = album_desc;
    }

    public int getIs_original_code() {
        return is_original_code;
    }

    public void setIs_original_code(int is_original_code) {
        this.is_original_code = is_original_code;
    }

    public String getVer_big_pic() {
        return ver_big_pic;
    }

    public void setVer_big_pic(String ver_big_pic) {
        this.ver_big_pic = ver_big_pic;
    }

    public String getHor_big_pic() {
        return hor_big_pic;
    }

    public void setHor_big_pic(String hor_big_pic) {
        this.hor_big_pic = hor_big_pic;
    }

    public String getVer_high_pic() {
        return ver_high_pic;
    }

    public void setVer_high_pic(String ver_high_pic) {
        this.ver_high_pic = ver_high_pic;
    }

    public String getHor_high_pic() {
        return hor_high_pic;
    }

    public void setHor_high_pic(String hor_high_pic) {
        this.hor_high_pic = hor_high_pic;
    }

    public long getCid() {
        return cid;
    }

    public void setCid(long cid) {
        this.cid = cid;
    }

    public String getCate_code() {
        return cate_code;
    }

    public void setCate_code(String cate_code) {
        this.cate_code = cate_code;
    }

    public String getSecond_cate_name() {
        return second_cate_name;
    }

    public void setSecond_cate_name(String second_cate_name) {
        this.second_cate_name = second_cate_name;
    }

    public String getAlbum_publish_time() {
        return publish_time;
    }

    public void setAlbum_publish_time(String album_publish_time) {
        this.publish_time = album_publish_time;
    }

    public int getIs_trailer() {
        return is_trailer;
    }

    public void setIs_trailer(int is_trailer) {
        this.is_trailer = is_trailer;
    }

    public int getIs_titbits() {
        return is_titbits;
    }

    public void setIs_titbits(int is_titbits) {
        this.is_titbits = is_titbits;
    }

    public int getTitbits_aid() {
        return titbits_aid;
    }

    public void setTitbits_aid(int titbits_aid) {
        this.titbits_aid = titbits_aid;
    }

    public String getDirector() {
        return director;
    }

    public void setDirector(String director) {
        this.director = director;
    }

    public String getMain_actor() {
        return main_actor;
    }

    public void setMain_actor(String main_actor) {
        this.main_actor = main_actor;
    }

    public String getActor() {
        return actor;
    }

    public void setActor(String actor) {
        this.actor = actor;
    }

    public String getModerator() {
        return moderator;
    }

    public void setModerator(String moderator) {
        this.moderator = moderator;
    }

    public long getArea_id() {
        return area_id;
    }

    public void setArea_id(long area_id) {
        this.area_id = area_id;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getTv_station() {
        return tv_station;
    }

    public void setTv_station(String tv_station) {
        this.tv_station = tv_station;
    }

    public String getTv_source() {
        return tv_source;
    }

    public void setTv_source(String tv_source) {
        this.tv_source = tv_source;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public long getTotal_video_count() {
        return total_video_count;
    }

    public void setTotal_video_count(long total_video_count) {
        this.total_video_count = total_video_count;
    }

    public long getLatest_video_count() {
        return latest_video_count;
    }

    public void setLatest_video_count(long latest_video_count) {
        this.latest_video_count = latest_video_count;
    }

    public float getScore() {
        return score;
    }

    public void setScore(float score) {
        this.score = score;
    }

    public long getPlay_count() {
        return play_count;
    }

    public void setPlay_count(long play_count) {
        this.play_count = play_count;
    }

    public String getUpdateNotification() {
        return updateNotification;
    }

    public void setUpdateNotification(String updateNotification) {
        this.updateNotification = updateNotification;
    }

    public String getDubbing() {
        return dubbing;
    }

    public void setDubbing(String dubbing) {
        this.dubbing = dubbing;
    }

    public String getShow_date() {
        return show_date;
    }

    public void setShow_date(String show_date) {
        this.show_date = show_date;
    }

    public String getOriginal_album_url() {
        return original_album_url;
    }

    public void setOriginal_album_url(String original_album_url) {
        this.original_album_url = original_album_url;
    }

    public String getAward() {
        return award;
    }

    public void setAward(String award) {
        this.award = award;
    }

    public String getDistribution_firm_pic() {
        return distribution_firm_pic;
    }

    public void setDistribution_firm_pic(String distribution_firm_pic) {
        this.distribution_firm_pic = distribution_firm_pic;
    }

    public String getBackground_image_pic() {
        return background_image_pic;
    }

    public void setBackground_image_pic(String background_image_pic) {
        this.background_image_pic = background_image_pic;
    }

    public ArrayList<YMS> getYms() {
        return yms;
    }

    public void setYms(ArrayList<YMS> yms) {
        this.yms = yms;
    }

    public long getCrid() {
        return crid;
    }

    public void setCrid(long crid) {
        this.crid = crid;
    }

    /**
     * @return the video_list
     */
    public ArrayList<AppPlatformModel> getVideo_list() {
        return video_list;
    }

    /**
     * @param video_list the video_list to set
     */
    public void setVideo_list(ArrayList<AppPlatformModel> video_list) {
        this.video_list = video_list;
    }

    /**
     * @return the site
     */
    public int getSite() {
        return site;
    }

    /**
     * @param site the site to set
     */
    public void setSite(int site) {
        this.site = site;
    }

    /**
     * @return the is_album
     */
    @Deprecated
    public int getIs_album() {
        return is_album;
    }

    /**
     * @param is_album the is_album to set
     */
    @Deprecated
    public void setIs_album(int is_album) {
        this.is_album = is_album;
    }

    /**
     * @return the tip
     */
    public String getTip() {
        return tip;
    }

    /**
     * @param tip the tip to set
     */
    public void setTip(String tip) {
        this.tip = tip;
    }

    /**
     * @return the tv_desc
     */
    public String getTv_desc() {
        return tv_desc;
    }

    /**
     * @param tv_desc the tv_desc to set
     */
    public void setTv_desc(String tv_desc) {
        this.tv_desc = tv_desc;
    }

    /**
     * @return the tv_name
     */
    public String getTv_name() {
        return tv_name;
    }

    /**
     * @param tv_name the tv_name to set
     */
    public void setTv_name(String tv_name) {
        this.tv_name = tv_name;
    }

    /**
     * @return the vid
     */
    public long getVid() {
        return vid;
    }

    /**
     * @param vid the vid to set
     */
    public void setVid(long vid) {
        this.vid = vid;
    }

    public float getDouban_score() {
        return douban_score;
    }

    public void setDouban_score(float douban_score) {
        this.douban_score = douban_score;
    }

    public String getAlias_name() {
        return alias_name;
    }

    public void setAlias_name(String alias_name) {
        this.alias_name = alias_name;
    }

    public String getOriginal_work() {
        return original_work;
    }

    public void setOriginal_work(String original_work) {
        this.original_work = original_work;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public int getTv_is_danmu() {
        return tv_is_danmu;
    }

    public void setTv_is_danmu(int tv_is_danmu) {
        this.tv_is_danmu = tv_is_danmu;
    }

    public int getSeason() {
        return season;
    }

    public void setSeason(int season) {
        this.season = season;
    }

    public String getBg_small_pic() {
        return bg_small_pic;
    }

    public void setBg_small_pic(String bg_small_pic) {
        this.bg_small_pic = bg_small_pic;
    }

    public String getBg_high_pic() {
        return bg_high_pic;
    }

    public void setBg_high_pic(String bg_high_pic) {
        this.bg_high_pic = bg_high_pic;
    }

    public String getBg_pic() {
        return bg_pic;
    }

    public void setBg_pic(String bg_pic) {
        this.bg_pic = bg_pic;
    }

    public String getBg_big_pic() {
        return bg_big_pic;
    }

    public void setBg_big_pic(String bg_big_pic) {
        this.bg_big_pic = bg_big_pic;
    }

    public String getHor_w16_pic() {
        return hor_w16_pic;
    }

    public void setHor_w16_pic(String hor_w16_pic) {
        this.hor_w16_pic = hor_w16_pic;
    }

    public String getVer_w12_pic() {
        return ver_w12_pic;
    }

    public void setVer_w12_pic(String ver_w12_pic) {
        this.ver_w12_pic = ver_w12_pic;
    }

    public int getEffective() {
        return effective;
    }

    public void setEffective(int effective) {
        this.effective = effective;
    }

    /**
     * 是否是片花专辑
     *
     * @return
     */
    public boolean isTrailerAlbum() {
        if (is_trailer == 1) {
            return true;
        }
        return false;
    }

    public void setHigh_light(ArrayList<String> high_light) {
        this.high_light = high_light;
    }

    public ArrayList<String> getHigh_light() {
        return high_light;
    }

    public void setVideos(ArrayList<AppPlatformVideoModel> videos) {
        this.videos = videos;
    }

    public ArrayList<AppPlatformVideoModel> getVideos() {
        return videos;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (aid ^ (aid >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        AlbumInfoModel other = (AlbumInfoModel) obj;
        if (aid != other.aid)
            return false;
        return true;
    }

    @Override
    public Object clone() {
        AlbumInfoModel albumModel = null;
        try {
            albumModel = (AlbumInfoModel) super.clone();
        } catch (CloneNotSupportedException e) {
            LogUtils.e(TAG, "copy AlbumInfoModel break out exception!", e);
        }
        return albumModel;
    }

    @Override
    public String toString() {
        return "AlbumInfoModel [data_type=" + data_type + ", aid=" + aid + ", album_name=" + album_name + ", cid="
                + cid + "]";
    }

    public long getTotal_duration() {
        return total_duration;
    }

    public void setTotal_duration(long total_duration) {
        this.total_duration = total_duration;
    }

    public List<AlbumInfoCompany> getCompany() {
        return company;
    }

    public void setCompany(List<AlbumInfoCompany> company) {
        this.company = company;
    }

    public PgcAccountInfoModel getPgcAccountInfo() {
        return user;
    }

    public void setUser(PgcAccountInfoModel pgcAccountInfo) {
        this.user = pgcAccountInfo;
    }

    public String getAlbumName() {
        if (StringUtils.isBlank(album_sub_name)) {
            return album_name;
        } else {
            return album_sub_name;
        }
    }

    /**
     * 是否专辑
     *
     * @return
     */
    public boolean isAlbumType() {
        return ListResourcesDataType.isTypeAlbum(data_type);
    }

    /**
     * 是否pgc类型
     *
     * @return
     */
    public boolean isPgcType() {
        return ListResourcesDataType.isSubTypePGC(data_type);
    }

    /**
     * 是否美剧
     *
     * @return
     */
    public boolean isUSVideoType() {
        return ListResourcesDataType.isSubTypeAmerican(data_type);
    }

    /**
     * 是否是付费类型
     *
     * @return
     */
    public boolean isPayVipType() {
        return ListResourcesDataType.isSubTypeVIP(data_type);
    }

    public boolean isPgcPayType() {
        return ListResourcesDataType.isSubTypePGCPay(data_type);
    }

    /**
     * 是否包含单集付费视频
     *
     * @return
     */
    public boolean isSinglePayType() {
        return ListResourcesDataType.isSinglePayType(data_type);
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    public int getDownload_type() {
        return download_type;
    }

    public void setDownload_type(int download_type) {
        this.download_type = download_type;
    }

    public String getWhole_source() {
        return whole_source;
    }

    public void setWhole_source(String whole_source) {
        this.whole_source = whole_source;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.data_type);
        dest.writeLong(this.aid);
        dest.writeLong(this.program_id);
        dest.writeInt(this.is_download);
        dest.writeInt(this.ip_limit);
        dest.writeInt(this.mobile_limit);
        dest.writeString(this.album_name);
        dest.writeString(this.album_sub_name);
        dest.writeString(this.album_desc);
        dest.writeInt(this.is_original_code);
        dest.writeString(this.ver_big_pic);
        dest.writeString(this.hor_big_pic);
        dest.writeString(this.ver_high_pic);
        dest.writeString(this.hor_high_pic);
        dest.writeLong(this.cid);
        dest.writeString(this.cate_code);
        dest.writeString(this.second_cate_name);
        dest.writeString(this.publish_time);
        dest.writeInt(this.is_trailer);
        dest.writeInt(this.is_titbits);
        dest.writeInt(this.titbits_aid);
        dest.writeString(this.director);
        dest.writeString(this.main_actor);
        dest.writeString(this.actor);
        dest.writeString(this.moderator);
        dest.writeLong(this.area_id);
        dest.writeString(this.area);
        dest.writeString(this.tv_station);
        dest.writeString(this.tv_source);
        dest.writeString(this.year);
        dest.writeLong(this.total_video_count);
        dest.writeLong(this.latest_video_count);
        dest.writeFloat(this.score);
        dest.writeLong(this.play_count);
        dest.writeString(this.updateNotification);
        dest.writeString(this.dubbing);
        dest.writeString(this.show_date);
        dest.writeString(this.original_album_url);
        dest.writeLong(this.crid);
        dest.writeString(this.award);
        dest.writeTypedList(this.company);
        dest.writeParcelable(this.user, flags);
        dest.writeString(this.bg_small_pic);
        dest.writeString(this.bg_high_pic);
        dest.writeString(this.bg_pic);
        dest.writeString(this.bg_big_pic);
        dest.writeString(this.hor_w16_pic);
        dest.writeString(this.ver_w12_pic);
        dest.writeString(this.distribution_firm_pic);
        dest.writeString(this.background_image_pic);
        dest.writeTypedList(this.yms);
        dest.writeList(this.video_list);
        dest.writeInt(this.site);
        dest.writeInt(this.is_album);
        dest.writeString(this.tip);
        dest.writeString(this.tips);
        dest.writeString(this.tv_desc);
        dest.writeString(this.tv_name);
        dest.writeLong(this.vid);
        dest.writeFloat(this.douban_score);
        dest.writeInt(this.season);
        dest.writeFloat(this.imdb_score);
        dest.writeString(this.alias_name);
        dest.writeString(this.original_work);
        dest.writeString(this.language);
        dest.writeInt(this.tv_is_danmu);
        dest.writeStringList(this.high_light);
        dest.writeTypedList(this.videos);
        dest.writeLong(this.total_duration);
        dest.writeInt(this.download_type);
        dest.writeInt(this.effective);
        dest.writeString(this.whole_source);
    }

    protected AlbumInfoModel(Parcel in) {
        this.data_type = in.readInt();
        this.aid = in.readLong();
        this.program_id = in.readLong();
        this.is_download = in.readInt();
        this.ip_limit = in.readInt();
        this.mobile_limit = in.readInt();
        this.album_name = in.readString();
        this.album_sub_name = in.readString();
        this.album_desc = in.readString();
        this.is_original_code = in.readInt();
        this.ver_big_pic = in.readString();
        this.hor_big_pic = in.readString();
        this.ver_high_pic = in.readString();
        this.hor_high_pic = in.readString();
        this.cid = in.readLong();
        this.cate_code = in.readString();
        this.second_cate_name = in.readString();
        this.publish_time = in.readString();
        this.is_trailer = in.readInt();
        this.is_titbits = in.readInt();
        this.titbits_aid = in.readInt();
        this.director = in.readString();
        this.main_actor = in.readString();
        this.actor = in.readString();
        this.moderator = in.readString();
        this.area_id = in.readLong();
        this.area = in.readString();
        this.tv_station = in.readString();
        this.tv_source = in.readString();
        this.year = in.readString();
        this.total_video_count = in.readLong();
        this.latest_video_count = in.readLong();
        this.score = in.readFloat();
        this.play_count = in.readLong();
        this.updateNotification = in.readString();
        this.dubbing = in.readString();
        this.show_date = in.readString();
        this.original_album_url = in.readString();
        this.crid = in.readLong();
        this.award = in.readString();
        this.company = in.createTypedArrayList(AlbumInfoCompany.CREATOR);
        this.user = in.readParcelable(PgcAccountInfoModel.class.getClassLoader());
        this.bg_small_pic = in.readString();
        this.bg_high_pic = in.readString();
        this.bg_pic = in.readString();
        this.bg_big_pic = in.readString();
        this.hor_w16_pic = in.readString();
        this.ver_w12_pic = in.readString();
        this.distribution_firm_pic = in.readString();
        this.background_image_pic = in.readString();
        this.yms = in.createTypedArrayList(YMS.CREATOR);
        this.video_list = new ArrayList<AppPlatformModel>();
        in.readList(this.video_list, AppPlatformModel.class.getClassLoader());
        this.site = in.readInt();
        this.is_album = in.readInt();
        this.tip = in.readString();
        this.tips = in.readString();
        this.tv_desc = in.readString();
        this.tv_name = in.readString();
        this.vid = in.readLong();
        this.douban_score = in.readFloat();
        this.season = in.readInt();
        this.imdb_score = in.readFloat();
        this.alias_name = in.readString();
        this.original_work = in.readString();
        this.language = in.readString();
        this.tv_is_danmu = in.readInt();
        this.high_light = in.createStringArrayList();
        this.videos = in.createTypedArrayList(AppPlatformVideoModel.CREATOR);
        this.total_duration = in.readLong();
        this.download_type = in.readInt();
        this.effective = in.readInt();
        this.whole_source = in.readString();
    }

    public static final Creator<AlbumInfoModel> CREATOR = new Creator<AlbumInfoModel>() {
        @Override
        public AlbumInfoModel createFromParcel(Parcel source) {
            return new AlbumInfoModel(source);
        }

        @Override
        public AlbumInfoModel[] newArray(int size) {
            return new AlbumInfoModel[size];
        }
    };
}
